﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ViCode_LeVi.Data;
using dotnetCHARTING.WinForms;
using ViCode_LeVi.Configs;
using System.Drawing.Drawing2D;
using ViCode_LeVi.Controls.Logs;

namespace ViCode_LeVi.Controls.Charts
{    
    public partial class PotentialPortfolioChart : ChartCtrl
    {
        //private string[] m_aChartAnnotations = new string[] { "Entwickeln", "Stabilisieren", "Analysieren", "Kein Handlungsbedarf" };
        private string[] m_aChartAnnotations = new string[] { "Develop", "Stabilize", "Analyze", "No need for action" };
        private FactorProperty[] m_aFactorProperties;
        private bool m_bXAxisAreaZoom;
        private double m_dMaxBubbleSize = 250.0;
        private double m_dXAxisMax;
        private double m_dXAxisMin;
        private double m_dYAxisMax;
        private double m_dYAxisMin;
        private dotnetCHARTING.WinForms.LabelAlignment m_eLabelAlignment;
       
        public override bool CreateChart()
        {
            LegendBox legendBox = null;
            bool flag = true;
            int riNumberOfElements = 0;
            try
            {
                base.m_sXAxisLabel = "Assessment";// "Bewertung (Mittelwert)";
                base.m_sYAxisLabel = " Relative Weighting";// "relative Weighting";
                base.SetChartBasis(eChartType.PotentialPortfolioChart, base.m_sXAxisLabel, base.m_sYAxisLabel);
                base.chart1.SeriesCollection.Clear();
                base.chart1.ExtraLegendBoxes.Clear();
                base.chart1.ExtraLegendEntries.Clear();
                base.chart1.XAxis.Markers.Clear();
                base.chart1.YAxis.Markers.Clear();
                base.chart1.SeriesCollection.Add(this.SetData(ref riNumberOfElements));
                NumberOfElements = riNumberOfElements;
                if ((base.NumberOfElements > 0) && (base.ChartLegendMode != eChartLegendMode.None))
                {
                    legendBox = this.GetExtraLegendBox(this.m_aFactorProperties);
                    base.chart1.ExtraLegendBoxes.Add(legendBox);
                }
                this.SetAxisBorder();
                Series series = new Series();
                Element element = new Element();
                series.LegendEntry.Visible = false;
                series.LegendEntry.Value = null;
                element.Name = "Empty";
                element.XValue = 20.0;
                element.YValue = 20.0;
                element.ShowValue = false;
                element.BubbleSize = this.m_dMaxBubbleSize;
                element.Color = System.Drawing.Color.Empty;
                element.LegendEntry.Visible = false;
                series.AddElements(new Element[] { element });
                base.chart1.SeriesCollection.Add(series);
                base.chart1.SeriesCollection.Add(this.SetAnnotations(this.m_aChartAnnotations));
                base.chart1.XAxis.ZeroTick = null;
                base.chart1.YAxis.ZeroTick = null;
                AxisMarker axisMarker = new AxisMarker("", new Line(System.Drawing.Color.DarkGray, System.Drawing.Drawing2D.DashStyle.Dash), (this.m_dXAxisMax + this.m_dXAxisMin) / 2.0)
                {
                    LegendEntry = { Visible = false }
                };
                base.chart1.XAxis.Markers.Add(axisMarker);
                AxisMarker marker2 = new AxisMarker("", new Line(Color.DarkGray, DashStyle.Dash), (this.m_dYAxisMax + this.m_dYAxisMin) / 2.0)
                {
                    LegendEntry = { Visible = false }
                };
                base.chart1.YAxis.Markers.Add(marker2);
                LegendEntry legendEntry = new LegendEntry("One or more unassessed dimension"/*"mindestens eine unbevalueste Dimension"*/, "")
                {
                    Marker = { Type = ElementMarkerType.FivePointStar, Size = 6 },
                    SeriesType = SeriesType.Marker
                };
                legendEntry.Marker.Color = Color.DarkBlue;
                legendEntry.Visible = true;
                base.chart1.LegendBox.ExtraEntries.Add(legendEntry);
                base.chart1.RefreshChart();
            }
            catch (Exception exception)
            {
                flag = false;                
                Log.LogException(exception);
            }
            return flag;
        }
        private Series SetAnnotations(string[] aChartAnnotations)
        {
            Series series = new Series();
            try
            {
                series.Type = SeriesType.Marker;
                series.LegendEntry.Visible = false;
                series.DefaultElement.Color = Color.Empty;
                //todo
                double yMin = -0.5;//this.m_dYAxisMin
                series.Elements.Add(this.GetAnnotationElement(this.m_dXAxisMin, this.m_dYAxisMax, aChartAnnotations[0], dotnetCHARTING.WinForms.Orientation.BottomRight));
                series.Elements.Add(this.GetAnnotationElement(this.m_dXAxisMax, this.m_dYAxisMax, aChartAnnotations[1], dotnetCHARTING.WinForms.Orientation.BottomLeft));
                series.Elements.Add(this.GetAnnotationElement(this.m_dXAxisMin, yMin, aChartAnnotations[2], dotnetCHARTING.WinForms.Orientation.TopRight));
                series.Elements.Add(this.GetAnnotationElement(this.m_dXAxisMax, yMin, aChartAnnotations[3], dotnetCHARTING.WinForms.Orientation.TopLeft));
            }
            catch (Exception exception)
            {
                series.Elements.Clear();
                Log.LogException(exception);
            }
            return series;
        }
        private Element GetAnnotationElement(double dXValue, double dYValue, string sChartAnnotation, dotnetCHARTING.WinForms.Orientation eOrientation)
        {
            Element element = new Element();
            Annotation annotation = null;
            try
            {
                element.XValue = dXValue;
                element.YValue = dYValue;
                element.ShowValue = false;
                annotation = new Annotation(sChartAnnotation)
                {
                    Label = { Font = new Font("Arial", 8f), Color = Color.Black }
                };
                annotation.ClearColors();
                annotation.DynamicSize = false;
                annotation.Orientation = eOrientation;
                element.Annotation = annotation;
            }
            catch (Exception exception)
            {
                Log.LogException(exception);
            }
            return element;
        }

        private void SetAxisBorder()
        {
            try
            {
                int num = 0;
                int num2 = 0;
                if (base.NumberOfElements <= 0)
                {
                    goto Label_034B;
                }
                double num3 = 0.0;
                double num4 = 100.0;
                double num5 = 0.0;
                double num6 = 100.0;
                foreach (FactorProperty property in this.m_aFactorProperties)
                {
                    num3 = Math.Max(num3, property.XPotential);
                    num5 = Math.Max(num5, property.YPotential);
                    num4 = Math.Min(num4, property.XPotential);
                    num6 = Math.Min(num6, property.YPotential);
                }
                num5 = Math.Ceiling(num5);
                num6 = Math.Floor(num6);
                if (this.XAxisAreaZoom)
                {
                    num3 = Math.Ceiling(num3);
                    num4 = Math.Floor(num4);
                }
                else
                {
                    num3 = 100.0;
                    num4 = 0.0;
                }
                if ((num3 - num4) <= 16.0)
                {
                    num = 1;
                    this.m_dXAxisMin = num4 - 0.5;
                    this.m_dXAxisMax = num3 + 0.5;
                }
                else
                {
                    if ((num3 - num4) > 51.0)
                    {
                        goto Label_01B0;
                    }
                    while ((num3 % 5.0) != 0.0)
                    {
                        num3++;
                    }
                    while ((num4 % 5.0) != 0.0)
                    {
                        num4--;
                    }
                    num = 5;
                    this.m_dXAxisMin = num4 - 2.5;
                    this.m_dXAxisMax = num3 + 2.5;
                }
                goto Label_020F;
            Label_01A4:
                num3++;
            Label_01B0:
                if ((num3 % 10.0) != 0.0)
                {
                    goto Label_01A4;
                }
                while ((num4 % 10.0) != 0.0)
                {
                    num4--;
                }
                num = 10;
                this.m_dXAxisMin = num4 - 5.0;
                this.m_dXAxisMax = num3 + 5.0;
            Label_020F:
                if ((num5 - num6) <= 8.0)
                {
                    num2 = 1;
                    this.m_dYAxisMin = num6 - 0.5;
                    this.m_dYAxisMax = num5 + 0.5;
                }
                else
                {
                    if ((num5 - num6) > 51.0)
                    {
                        goto Label_02E4;
                    }
                    while ((num5 % 5.0) != 0.0)
                    {
                        num5++;
                    }
                    while ((num6 % 5.0) != 0.0)
                    {
                        num6--;
                    }
                    num2 = 5;
                    this.m_dYAxisMin = num6 - 1.0;
                    this.m_dYAxisMax = num5 + 1.0;
                }
                goto Label_038D;
            Label_02D6:
                num5++;
            Label_02E4:
                if ((num5 % 10.0) != 0.0)
                {
                    goto Label_02D6;
                }
                while ((num6 % 10.0) != 0.0)
                {
                    num6--;
                }
                num2 = 10;
                this.m_dYAxisMin = num6 - 5.0;
                this.m_dYAxisMax = num5 + 5.0;
                goto Label_038D;
            Label_034B:
                this.m_dXAxisMax = 105.0;
                this.m_dYAxisMax = 105.0;
                this.m_dXAxisMin = -5.0;
                this.m_dYAxisMin = -5.0;
                num = 10;
                num2 = 10;
            Label_038D:
                base.chart1.XAxis.Minimum = this.m_dXAxisMin;
                base.chart1.XAxis.Maximum = this.m_dXAxisMax;
                base.chart1.YAxis.Minimum = - 0.5;// this.m_dYAxisMin;//hard code//todo
                base.chart1.YAxis.Maximum = this.m_dYAxisMax;
                base.chart1.XAxis.Interval = num;
                base.chart1.YAxis.Interval = num2;
            }
            catch (Exception exception)
            {
                Log.LogException(exception);
            }
        }
        private LegendBox GetExtraLegendBox(FactorProperty[] aFactorProperties)
        {
            bool flag = true;
            LegendBox box = new LegendBox();
            string psLegendEntryText = string.Empty;
            try
            {
                box.Background = base.chart1.TitleBox.Background;
                box.CornerBottomRight = BoxCorner.Square;
                box.CornerBottomLeft = BoxCorner.Square;
                box.CornerTopLeft = BoxCorner.Square;
                box.CornerTopRight = BoxCorner.Square;
                box.LabelStyle = new dotnetCHARTING.WinForms.Label("", new Font("Arial", 8f), Color.Black);
                box.Line = new Line(Color.Black);
                box.Shadow.Soft = true;
                box.Shadow.Color = Color.Gray;
                box.Shadow.Depth = 5;
                box.ListTopToBottom = true;
                box.Orientation = base.ExtraLegendBoxOrientation;
                box.Template = "%Icon %Value";
                if (aFactorProperties != null)
                {
                    foreach (FactorProperty property in aFactorProperties)
                    {
                        Color hK = new Color();
                        FactorType type = property.Type;
                        if (type != FactorType.HK)
                        {
                            if (type == FactorType.SK)
                            {
                                goto Label_0107;
                            }
                            if (type == FactorType.BK)
                            {
                                goto Label_0110;
                            }
                        }
                        else
                        {
                            hK = VMConfig.Intance.Colors.HK;
                        }
                        goto Label_0117;
                    Label_0107:
                        hK = VMConfig.Intance.Colors.SK;
                        goto Label_0117;
                    Label_0110:
                        hK = VMConfig.Intance.Colors.BK;
                    Label_0117:
                        switch (base.ChartLegendMode)
                        {
                            case eChartLegendMode.Full:
                                psLegendEntryText = string.Format("{0}: {1}", property.Id, property.Name);
                                break;

                            case eChartLegendMode.Short:
                                psLegendEntryText = property.Id;
                                break;
                        }
                        if (base.LegendWithPercent)
                        {
                            string str2;
                            string str3;
                            string str4;
                            this.GetQQSValues(property, out str3, out str2, out str4);
                            psLegendEntryText = psLegendEntryText + string.Format(" (Qn:{0} Ql:{1} Sy:{2})", str3, str2, str4);
                        }
                        LegendEntry legendEntry = new LegendEntry
                        {
                            SeriesType = SeriesType.Marker
                        };
                        legendEntry.Marker.Type = ElementMarkerType.Circle;
                        legendEntry.Marker.Size = 10;
                        legendEntry.Marker.Color = hK;
                        legendEntry.Value = base.FormatLegendEntryText(psLegendEntryText);
                        box.ExtraEntries.Add(legendEntry);
                    }
                }
                return box;
            }
            catch (Exception exception)
            {
                flag = false;
                Log.LogException(exception);
            }
            finally
            {
                if (!flag)
                {
                    box.ExtraEntries.Clear();
                }
            }
            return box;
        }
        public Func<Step_TaskItemGroup[]> Func_GetStep_TaskItemGroup;
        private FactorProperty[] GetFactorProperties()
        {
            RootData oProject = RootData.Intance;
            bool flag = true;
            bool filterFactorTypeHK = false;
            List<FactorProperty> list = new List<FactorProperty>();
            FactorProperty property = new FactorProperty();
            Step_TaskItemGroup[] grps = Func_GetStep_TaskItemGroup == null ? RootData.TaskItemGroups_Source : Func_GetStep_TaskItemGroup();
            if (grps == null)
                return new FactorProperty[0];
            foreach (var group in grps )
            {
                var data = group.Tasks_Source.Select(c => new FactorProperty()
                {
                    Quality = c.Quanlity_WeightPercent.HasValue == false ? 0 : (double)c.Quanlity_WeightPercent.Value
                     ,
                    Quantity = c.Quantity_WeightPercent.HasValue == false ? 0 : (double)c.Quantity_WeightPercent.Value
                     ,
                    Systematic = c.Systematic_WeightPercent.HasValue == false ? 0 : (double)c.Systematic_WeightPercent.Value
                     ,
                    Importance = c.Weight
                     ,
                    Name = c.Name
                     ,
                    XPercent = 0
                     ,
                    YPercent = 0
                     ,
                    Id = c.ID,
                    BubblePercent = 0,
                    BubbleSize = (c.Systematic_WeightPercent.HasValue == false ? 0 : (double)c.Systematic_WeightPercent.Value)+25,
                    Marker = string.Empty
                     ,
                    XPotential = c.Quanlity_WeightPercent.HasValue == false ? 0 : (double)c.Quanlity_WeightPercent.Value
                     ,
                    YPotential = c.Weight
                     ,
                    Type = group.FactorType
                     ,
                    ImportancePercent = 0
                     ,
                    EvaluatedDimensions = 50
                }).ToArray();
                list.AddRange(data);
            }
            return list.ToArray(); ;
            //QQSRecord record = null;
            //FactorExtension extension = null;
            try
            {
            //    if (oProject != null)
            //    {
            //        Hashtable hashtable = DH.CalcRelativeImportance(oProject, oProject.CurrentPeriod, true);
            //        FactorList list2 = oProject.ValidFactorsForCurrentPeriod(true);
            //        if (list2 == null)
            //        {
            //            return list;
            //        }
            //        foreach (Factor factor in list2)
            //        {
            //            if (((factor == null) || (factor.Type == FactorType.GE)) || ((factor.Type == FactorType.GP) || (factor.Type == FactorType.UNKNOWN)))
            //            {
            //                continue;
            //            }
            //            record = factor.QQSForPeriod(oProject.CurrentPeriod);
            //            extension = factor.ExtensionForPeriod(oProject.CurrentPeriod);
            //            if ((record == null) || (extension == null))
            //            {
            //                continue;
            //            }
            //            FactorType type = factor.Type;
            //            if (type != FactorType.HK)
            //            {
            //                if (type == FactorType.SK)
            //                {
            //                    goto Label_00D7;
            //                }
            //                if (type == FactorType.BK)
            //                {
            //                    goto Label_00E0;
            //                }
            //                goto Label_00E9;
            //            }
            //            filterFactorTypeHK = base.FilterFactorTypeHK;
            //            goto Label_00EB;
            //        Label_00D7:
            //            filterFactorTypeHK = base.FilterFactorTypeSK;
            //            goto Label_00EB;
            //        Label_00E0:
            //            filterFactorTypeHK = base.FilterFactorTypeBK;
            //            goto Label_00EB;
            //        Label_00E9:
            //            filterFactorTypeHK = false;
            //        Label_00EB:
            //            if (filterFactorTypeHK)
            //            {
            //                property = new FactorProperty();
            //                string str = string.Empty;
            //                int num = 0;
            //                if (record.QualityUsed && (record.QualityAsIs != DH.INVALID_INT))
            //                {
            //                    property.Quality = record.QualityAsIs;
            //                    num++;
            //                }
            //                else
            //                {
            //                    property.Quality = 0.0;
            //                    str = str + "Ql";
            //                }
            //                if (record.QuantityUsed && (record.QuantityAsIs != DH.INVALID_INT))
            //                {
            //                    property.Quantity = record.QuantityAsIs;
            //                    num++;
            //                }
            //                else
            //                {
            //                    property.Quantity = 0.0;
            //                    str = str + "Qn";
            //                }
            //                if (record.SystematicsUsed && (record.SystematicsAsIs != DH.INVALID_INT))
            //                {
            //                    property.Systematic = record.SystematicsAsIs;
            //                    num++;
            //                }
            //                else
            //                {
            //                    property.Systematic = 0.0;
            //                    str = str + "Sy";
            //                    if (!Config.Charts.PortfolioCorrectMissingDimensions)
            //                    {
            //                        filterFactorTypeHK = false;
            //                    }
            //                }
            //                if (num > 0)
            //                {
            //                    property.Id = factor.LogicalID;
            //                    property.Name = factor.Name;
            //                    property.Type = factor.Type;
            //                    property.XPotential = Math.Round((double)(((property.Quality + property.Quantity) + property.Systematic) / ((double)num)), 2);
            //                    property.YPotential = Math.Round(Convert.ToDouble(hashtable[factor.ID]), 2);
            //                    property.BubbleSize = property.Systematic + 25.0;
            //                    property.Importance = extension.Importance;
            //                    property.Marker = str;
            //                    property.EvaluatedDimensions = num;
            //                }
            //                else
            //                {
            //                    filterFactorTypeHK = false;
            //                }
            //                if (filterFactorTypeHK)
            //                {
            //                    list.Add(property);
            //                }
            //            }
            //        }
            //    }
                return list.ToArray();
            }
            catch (Exception exception)
            {
                flag = false;
                Log.LogException(exception);
            }
            finally
            {
                if (!flag)
                {
                    list.Clear();
                }
            }
            return list.ToArray();
        }

        private void GetQQSValues(FactorProperty oProperty, out string sQuantity, out string sQuality, out string sSystematic)
        {
            if ((oProperty.Quantity % 1.0) == 0.0)
            {
                sQuantity = oProperty.Quantity.ToString("0") + "%";
            }
            else
            {
                sQuantity = oProperty.Quantity.ToString("0.00") + "%";
            }
            if ((oProperty.Quality % 1.0) == 0.0)
            {
                sQuality = oProperty.Quality.ToString("0") + "%";
            }
            else
            {
                sQuality = oProperty.Quality.ToString("0.00") + "%";
            }
            if ((oProperty.Systematic % 1.0) == 0.0)
            {
                sSystematic = oProperty.Systematic.ToString("0") + "%";
            }
            else
            {
                sSystematic = oProperty.Systematic.ToString("0.00") + "%";
            }
            //todo
            string sMarker = oProperty.Marker;
            if (sMarker == null)
            {
                sMarker = string.Empty;
            }
            for (int i = 0; i < (sMarker.Length / 2); i++)
            {
                string str2 = oProperty.Marker.Substring(i * 2, 2);
                if (str2 != null)
                {
                    if (!(str2 == "Ql"))
                    {
                        if (str2 == "Qn")
                        {
                            goto Label_0156;
                        }
                        if (str2 == "Sy")
                        {
                            goto Label_015F;
                        }
                    }
                    else
                    {
                        sQuality = " - ";
                    }
                }
                continue;
            Label_0156:
                sQuantity = " - ";
                continue;
            Label_015F:
                sSystematic = " - ";
            }
        }


        public dotnetCHARTING.WinForms.LabelAlignment LabelAlignment
        {
            get
            {
                return this.m_eLabelAlignment;
            }
            set
            {
                this.m_eLabelAlignment = value;
            }
        }

        public double MaxBubbleSize
        {
            get
            {
                return this.m_dMaxBubbleSize;
            }
            set
            {
                this.m_dMaxBubbleSize = value;
            }
        }

        public bool XAxisAreaZoom
        {
            get
            {
                return this.m_bXAxisAreaZoom;
            }
            set
            {
                this.m_bXAxisAreaZoom = value;
            }
        }
        protected override SeriesCollection SetData(ref int riNumberOfElements)
        {
            SeriesCollection seriess = new SeriesCollection();
            try
            {
                Series series = new Series
                {
                    Name = RootData.Intance.Report_SucessFactor_Human//"Human Capital"//"Human Capital"
                };
                series.DefaultElement.Color = VMConfig.Intance.Colors.HK;
                series.DefaultElement.SmartLabel.Alignment = this.LabelAlignment;
                Series series2 = new Series
                {
                    Name = RootData.Intance.Report_SucessFactor_Relational//"Relational Capital" //"Relational Capital"
                };
                series2.DefaultElement.Color = VMConfig.Intance.Colors.BK;
                series2.DefaultElement.SmartLabel.Alignment = this.LabelAlignment;
                Series series3 = new Series
                {
                    Name = RootData.Intance.Report_SucessFactor_Structural//"Structural Capital"//"Structural Capital"
                };
                series3.DefaultElement.Color = VMConfig.Intance.Colors.SK;
                series3.DefaultElement.SmartLabel.Alignment = this.LabelAlignment;
                this.m_aFactorProperties = this.GetFactorProperties();
                foreach (FactorProperty property in this.m_aFactorProperties)
                {
                    string str;
                    string str2;
                    string str3;
                    Element element = new Element();
                    bool flag = true;
                    this.GetQQSValues(property, out str2, out str, out str3);
                    element.Name = property.Name;
                    element.XValue = property.XPotential;
                    element.YValue = property.YPotential;
                    element.ShowValue = true;
                    element.SmartLabel.Color = Color.Black;
                    element.SmartLabel.DynamicPosition = true;
                    if (property.EvaluatedDimensions < 3)
                    {
                        element.ForceMarker = true;
                        element.Marker = new ElementMarker(ElementMarkerType.FivePointStar, 6, Color.DarkBlue);
                    }
                    string str4 = string.Empty;
                    switch (base.ChartLabelMode)
                    {
                        case eChartLabelMode.Full:
                            element.SmartLabel.Text = property.Id + ": " + property.Name;
                            break;

                        case eChartLabelMode.FullWithValue:
                            str4 = string.Format("QQS:{0}% Gew:{1}% Sy:{2}", ((property.XPotential % 1.0) == 0.0) ? property.XPotential.ToString("0") : property.XPotential.ToString("0.00"), property.YPotential.ToString("0.00"), str3);
                            element.SmartLabel.Text = string.Format("{0}: {1}: ({2})", property.Id, property.Name, str4);
                            break;

                        case eChartLabelMode.Short:
                            element.SmartLabel.Text = property.Id;
                            break;

                        case eChartLabelMode.ShortWithValue:
                            str4 = string.Format("QQS:{0}% Gew:{1}% Sy:{2}", ((property.XPotential % 1.0) == 0.0) ? property.XPotential.ToString("0") : property.XPotential.ToString("0.00"), property.YPotential.ToString("0.00"), str3);
                            element.SmartLabel.Text = string.Format("{0}: ({1})", property.Id, str4);
                            break;

                        default:
                            element.SmartLabel.Text = property.Id;
                            break;
                    }
                    if (base.LabelWithPercent)
                    {
                        SmartLabel smartLabel = element.SmartLabel;
                        smartLabel.Text = smartLabel.Text + string.Format("\n(QQS-Mittelwert: {0}%\nrelative Weighting: {1}%\nSystematic: {2})", property.XPotential, property.YPotential, str3);
                    }
                    switch (base.ChartToolTipMode)
                    {
                        case eChartToolTipMode.Full:
                            element.ToolTip = property.Name;
                            break;

                        case eChartToolTipMode.Percent:
                            element.ToolTip = string.Format("Quantity: {0}\n Quanlity: {1}\n Systematic: {2}\n Absolute Weighting: {3}", new object[] { str2, str, str3, property.Importance });
                            break;

                        case eChartToolTipMode.FullPercent:
                            element.ToolTip = string.Format("{0}\n(Quantity: {1}\n Quanlity: {2}\n Systematic: {3}\n Absolute Weighting: {4})", new object[] { property.Name, str2, str, str3, property.Importance });
                            break;
                        case eChartToolTipMode.None:
                            element.ToolTip = property.Name;
                            break;

                    }
                    if (str3 == " - ")
                    {
                        //if (Config.Charts.PortfolioCorrectMissingDimensions)
                        //{
                        //    element.BubbleSize = Config.Charts.MissingDimensionsValue + 0x19;
                        //}
                        //else
                        //{
                        //    flag = false;
                        //}
                    }
                    else
                    {
                        element.BubbleSize = property.BubbleSize;
                    }
                    if (flag)
                    {
                        FactorType type = property.Type;
                        if (type != FactorType.HK)
                        {
                            if (type == FactorType.SK)
                            {
                                goto Label_049F;
                            }
                            if (type == FactorType.BK)
                            {
                                goto Label_047F;
                            }
                        }
                        else if (base.FilterFactorTypeHK)
                        {
                            series.AddElements(new Element[] { element });
                        }
                    }
                    continue;
                Label_047F:
                    if (base.FilterFactorTypeBK)
                    {
                        series2.AddElements(new Element[] { element });
                    }
                    continue;
                Label_049F:
                    if (base.FilterFactorTypeSK)
                    {
                        series3.AddElements(new Element[] { element });
                    }
                }
                if (series.Elements.Count > 0)
                {
                    seriess.Add(series);
                }
                if (series3.Elements.Count > 0)
                {
                    seriess.Add(series3);
                }
                if (series2.Elements.Count > 0)
                {
                    seriess.Add(series2);
                }
                riNumberOfElements = (series.Elements.Count + series2.Elements.Count) + series3.Elements.Count;
            }
            catch (Exception exception)
            {
                seriess.Clear();
                Log.LogException(exception);
            }
            return seriess;
        }
    }
}
